package com.gismore.demo.common.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;

import com.gismore.demo.common.RET;

/**
 * Created by lei on 2017/5/31.
 */
@Component
public class LocaleMessageSourceService {

	@Autowired
	private MessageSource messageSource;

	/**
	 * 根据
	 * @param messageKey
	 * @return
	 */
	public String getMessage(String messageKey) {
		String message = messageSource.getMessage(messageKey, null, LocaleContextHolder.getLocale());
		return message;
	}

	public RET getMessage(Integer code){
		return new RET(code,getMessage("code."+code));
	}

}
